package com.quanyan.stadium.service;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.stadium.api.req.*;
import com.quanyan.stadium.api.req.v2.ReqUpdateOpponent;
import com.quanyan.stadium.api.resp.*;
import com.quanyan.stadium.api.resp.v2.RespClubAbstract;
import com.quanyan.stadium.api.resp.v2.RespGameSystem;
import com.quanyan.stadium.api.resp.v2.RespGameSystemAndUserClubMsg;
import com.quanyan.stadium.entity.TbGameEvent;
import com.quanyan.stadium.entity.TbUserGameSchedule;
import com.quanyan.stadium.entity.vo.GameEvent;
import com.quanyan.stadium.entity.vo.GameRound;
import com.quanyan.stadium.entity.vo.GameSchedule;
import com.quanyan.stadium.entity.vo.GameTeam;
import com.quanyan.stadium.enums.GameCategoryConfigEnum;
import com.quanyan.stadium.enums.GameGradeLevelConfigEnum;
import com.quanyan.stadium.enums.GameSystemConfigEnum;
import com.quanyan.stadium.enums.PayTypeEnum;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;


public interface GameEventService {

    /**
     * 轮次完结,最后一轮的完结比较复杂一点
     *
     * @param reqFinishGameEvent
     *
     * @return APIResponse null
     * */

    APIResponse finishGameRound(ReqFinishGameEvent reqFinishGameEvent, Integer uid);

    /**
     * 赛事完结,只有在最后一轮所有的积分录入完毕以后,才能默认完成
     *
     * @param reqFinishGameEvent
     *
     * @return APIResponse null
     * */

    APIResponse finishGameEvent(ReqFinishGameEvent reqFinishGameEvent, Integer uid);

    /**
     * 用户操作失误，自己已经组织比赛，需要跟正常完结比赛一样将钱退到组织者账户中
     */
    APIResponse finishGameEvent(Integer gameEventId);

    /**
     * 赛事完结,只有在最后一轮所有的积分录入完毕以后,才能默认完成（只用于个人赛）
     *
     * 注意:isEffective：是否有效，有效的话会发MQ消息
     */

    APIResponse finishPersonaPersonalGameEvent(ReqFinishGameEvent reqFinishGameEvent, Integer uid,Boolean isEffective);

    /**
     * 赛事取消
     *
     * @param gameEventId
     *
     * @return APIResponse null
     * */

    APIResponse cancelClubGameEvent(Integer gameEventId);

    /**
     * 俱乐部常驻球馆
     *
     * @param clubId
     *
     * @return APIResponse 赛事基本信息
     * */

    APIResponse<List<GameEvent>> getClubPlaceGameEventList(Integer clubId, Integer districtId, Integer categoryId) throws InvocationTargetException, IllegalAccessException;

    /**
     * 俱乐部创建积分赛事
     *
     * @param uid 用户id
     * @param createIntegrateGame 积分赛事创建所需对象
     *
     * @return APIResponse 赛事基本信息
     * */


    APIResponse<GameEvent> clubCreateGameEvent(Integer uid, ReqCreateClubGameEvent createIntegrateGame) throws InvocationTargetException, IllegalAccessException;

    /**
     * 某栏目下的可用赛制和玩法选择
     *
     * 羽毛球\网球  不支持混合赛制,不然后期逻辑容易出问题<注意>
     *
     * @param categoryId
     *
     * @return APIResponse 某栏目下的可用赛制和玩法选择
     * */
    APIResponse<RespGameSystemAndGameCategory> gameCategoryAndSystem(Integer categoryId, Byte gameType);

    /**
     * 某栏目下的可用赛制和玩法选择
     *
     * 羽毛球\网球  不支持混合赛制,不然后期逻辑容易出问题<注意>
     *
     * @param categoryId
     *
     * @return APIResponse 某栏目下的可用赛制和玩法选择
     * */
    List<RespGameSystem> gameCategoryAndSystemV2(Integer categoryId);

    /**
     * 获取赛事分项、赛制以及用户可管理俱乐部列表
     *
     */
    RespGameSystemAndUserClubMsg getGameSystemAndUserClubMsg(Integer categoryId,Integer uid);


    /**
     * 存在混合制,添加相应的信息
     *
     * @param reqGroupNumAndRankNum
     *
     * */
    APIResponse<RespGameRoundAndGameTeam> updateGroupNumAndRankNum(ReqGroupNumAndRankNum reqGroupNumAndRankNum) throws Exception;

    /**
     * 根据 赛事id获取轮次信息和当钱参赛人数信息
     * @param gameEventId
     *
     * */
    APIResponse<RespGameRoundAndGameTeam> gameRoundAndGameTeam(Integer gameEventId) throws Exception;


    /**
     * 根据 赛事id,获取参与的队伍
     *
     * @param gameEventId
     *
     * */
    PageObj<List<GameTeam>> gameTeamByGameEventId(Integer gameEventId, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException;

    /**
     * 根据 赛事id,获取参与的队伍
     *
     * @param event
     *
     * */
    PageObj<List<GameTeam>> gameTeamByGameEvent(TbGameEvent event, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException;

    /**
     * 根据 俱乐部id,获取俱乐部创建的赛事列表
     *
     * @param clubId
     *
     * */
    APIResponse clubGameEventList(Integer clubId, Integer pageNum, Integer pageSize, Integer uid) throws InvocationTargetException, IllegalAccessException;

    /**
     * 官方赛事详情展示
     *
     * @param
     *
     * */
    APIResponse<RespGameEventDetail> gameEventDetail(Integer gameEventId, Integer uid);
    /**
     * 官方赛程列表,只显示已经生成对战表的轮次
     * @param gameEventId 赛事id
     *
     * @param
     *
     * */
    APIResponse<List<GameRound>>  gameGroundList(Integer gameEventId, Integer uid) throws InvocationTargetException, IllegalAccessException;

    /**
     * 官方赛程列表,只显示已经生成对战表的轮次的赛程
     * @param gameRoundId 赛事id
     *
     *
     * */
    List<GameSchedule> gameSchedule(Integer gameRoundId, Integer gameEventId);

    /**
     * 官方赛程列表,只显示已经生成对战表的轮次的赛程,继承类
     * @param gameRoundId 赛事id
     *
     * */
    List<GameSchedule> gameScheduleList(Integer gameRoundId,TbGameEvent gameEvent);

    /**
     * 官方赛程列表,只显示已经生成对战表的轮次的赛程,继承类 ,用户的赛程信息
     * @param gameRoundId 赛事id
     *
     * */
    List<GameSchedule> userGameScheduleList(Integer gameRoundId, TbGameEvent gameEvent, List<Integer> userScheduleIds, Map<Integer, TbUserGameSchedule> userGameScheduleMap);
    /**
     * 官方比赛的数据列表,只显示已经生成对战表数据
     * @param gameEventId 赛事id
     *
     * */
    RespGameEventData gameEventData(Integer gameEventId, Integer pageNum, Integer pageSize);
    /**
     * 获取某场馆下的积分列表
     *
     * @param
     *
     * */
    APIResponse<PageObj<List<RespOfficialGameTeam>>> placeScoreRankList(Integer gameEventId, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException;

    /**
     * 获取某场馆下的积分赛事列表
     *
     * @param
     *
     * */
    APIResponse<?> placeGameEventList(Integer gameEventId) throws InvocationTargetException, IllegalAccessException;

    /**
     * 获取某场馆下的积分赛事列表
     *  @param
     *
     * */
    APIResponse<PageObj<List<RespOfficialGameEvent>>> searchGameEventList(ReqSearchGameEvent reqSearchGameEvent, Integer uid) throws InvocationTargetException, IllegalAccessException;
    /**
     * 官方活动下的小活动
     *
     * @param
     *
     * */
    Map<Integer, List<GameEvent>> gameEventListMap(Integer uid, List<Integer> gameEventIds, Integer pageNum, Integer pageSize, ReqSearchGameEvent reqSearchGameEvent) throws InvocationTargetException, IllegalAccessException;
    /**
     * 用户参加的赛事
     *
     * @param
     *
     * */
    List<Integer> userGameEventIds(Integer uid, Integer categoryId);
    /**
     * 用户所在俱乐部发布的赛事列表
     *
     * @param
     *
     * */
    List<Integer> userClubPublishGameEventIds(Integer uid, Integer categoryId);
    /**
     * 邀请用户根据赛事id和用户电话
     *
     * @param
     *
     * */
    APIResponse inviteUserByMobile(Integer gameEventId, String mobile, Integer uid) throws InvocationTargetException, IllegalAccessException;
    /**
     * 获取当前轮次下用户参与的赛程id
     *
     * @param
     *
     * */
    List<Integer> queryScheduleIdByGameRoundIdAndUid(List<Integer> uidTemp1, Integer gameEventId, List<GameSchedule> temp, Integer uid);
    /**
     * 根据俱乐部id,显示最优的3个赛事
     *
     * @param
     *
     * */
    List<GameEvent> getResGameEventsByClubId(Integer clubId) throws InvocationTargetException, IllegalAccessException;

    RespGameSystemAndGameCategory generateGameSystemAndGameCategory(List<GameCategoryConfigEnum> categories, List<GameSystemConfigEnum> systems,
                                                                            List<GameGradeLevelConfigEnum> gradeLevels, List<PayTypeEnum> payTypes, Integer categoryId);

    /**
     * 个人对抗赛比分录入
     */
    String recordResultForPersonalAgainst(Integer uid, ReqRecordGameScheduleResult req);

    /**
     * 个人赛详情页
     */
    RespPersonalGameEventDetail selectPersonalGameEventDetail(Integer gameEventId,Integer uid);

    /**
     * 个人赛比分录入超过7天没确认，锁定比分并结束比赛
     */
    void lockScoreAndEndPersonalGameEvents();

    /**
     * 个人赛比赛开始报名未满，自动结束比赛
     */
    void endPersonalGameEvents();

    /**
     * 个人对抗赛详情页悬浮消息
     */
    RespScoreMsg getRecordResultMessage(Integer gameEventId,Integer uid);

    /**
     * 用户比分录入V2
     */
    int userRecordScoreV2(Integer uid, ReqRecordGameScheduleResult reqId);

    /**
     * 赛事编排V2
     * @param reqUpdateOpponent
     */
    void updateOpponentV2(ReqUpdateOpponent reqUpdateOpponent);

    /**
     *
     * 用户俱乐部信息
     */
    Map<Integer, List<RespClubAbstract>> getUserClubMsg(Integer uid);
}
